#
# Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
#

Import('BuildEnv')
env = BuildEnv.Clone()

cli_setup_sources = [
                'setup.py',
                'entry_points.py',
          ]

cli_setup_sources_rules = []
for file in cli_setup_sources:
    cli_setup_sources_rules.append(
        env.Install(Dir("."), '#controller/src/utils/contrail-cli/contrail_control_cli/' + file))

local_sources = [
                '__init__.py',
                'main.py',
                'commandlist.py',
        ]

local_sources_rules = []
for file in local_sources:
    local_sources_rules.append(env.Install(Dir("ContrailControlCli"), file))

cli_sdist_depends = [cli_setup_sources_rules, local_sources_rules]

cd_cmd = 'cd ' + Dir('.').path + ' && '
cli_sdist_gen = env.Command('dist/contrail_control_cli-0.1dev.tar.gz',
                                'setup.py',
                                cd_cmd + 'python setup.py sdist')
# install everything before building distribution
env.Depends(cli_sdist_gen, cli_sdist_depends)

env.Default(cli_sdist_gen)
install_cmd = env.Command(None,
                        'setup.py',
                        cd_cmd + 'python setup.py install %s' %
                        env['PYTHON_INSTALL_OPT'])
env.Depends(install_cmd, cli_sdist_depends)
env.Depends('install', install_cmd)
